package sanbing.jcpplearning;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class ByteBufCapacityExample {
    public static void main(String[] args) {
        // 创建一个 ByteBuf，初始容量为 5，最大容量为 20
        ByteBuf buffer = Unpooled.buffer(5, 20);

        System.out.println("Initial capacity: " + buffer.capacity()); // 输出 5

        // 写入超出初始容量的数据
        buffer.writeBytes(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});

        System.out.println("New capacity: " + buffer.capacity()); // 自动扩容，输出容量大于 5
    }
}